#! /bin/sh

name=python
repology_srcname=python
version=3.13.3
revision=1
tarball_url="https://www.python.org/ftp/python/${version}/Python-${version}.tar.xz"
tarball_blake2b="24ac47c13cbfa4dc9ce6ae4d18d7b5310f83ac1f4f18722138ef07e01cb8ac37edf6f4301983cb468f533b9b475b5a9d761d3044e61c7ccaa99dceadb954fe34"
hostdeps="gcc pkg-config"
deps="core-libs bzip2 xz zlib openssl ncurses readline gdbm libexpat libffi"

prepare() {
    autotools_recursive_regen
}

configure() {
        ac_cv_file__dev_ptmx=yes \
        ac_cv_file__dev_ptc=yes \
        ac_cv_func_sched_setscheduler=no \
        ac_cv_buggy_getaddrinfo=no \
    autotools_configure \
        --build=$ARCHITECTURE \
        --with-computed-gotos \
        --disable-optimizations \
        --enable-ipv6 \
        --with-system-expat \
        --enable-loadable-sqlite-extensions \
        --without-ensurepip \
        --with-tzpath=${prefix}/share/zoneinfo \
        --with-build-python=python3 \
        --without-static-libpython
}

build() {
    make -j${parallelism}
}

package() {
    DESTDIR="${dest_dir}" make install

    ln -sfv python3 "${dest_dir}${prefix}"/bin/python
    ln -sfv python3-config "${dest_dir}${prefix}"/bin/python-config
    ln -sfv pydoc3 "${dest_dir}${prefix}"/bin/pydoc
    ln -sfv idle3 "${dest_dir}${prefix}"/bin/idle

    post_package_strip
}
